/**Ancient Cipher UVA 1339*/
#include<bits/stdc++.h>
using namespace std;
const int maxn = 105;
char str1[maxn], str2[maxn];
int ar1[30], ar2[30];
int main() {
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  while(cin>>str1>>str2) {
    memset(ar1, 0x0, sizeof(ar1));
    memset(ar2, 0x0, sizeof(ar2));
    for(char ch:str1) {
      if(ch=='\0')break;
      ++ar1[ch - 'A'];
    }
    sort(begin(ar1), end(ar1));
    for(char ch:str2) {
      if(ch=='\0')break;
      ++ar2[ch - 'A'];
    }
    sort(begin(ar2), end(ar2));
    if(memcmp(ar1, ar2, sizeof(ar1))==0) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
